package com.hhp.cloud.shop.admin.controller;

import java.util.Arrays;


import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hhp.cloud.shop.admin.pojo.entity.RolePermissionEntity;
import com.hhp.cloud.shop.admin.service.RolePermissionService;

import com.hhp.cloud.shop.common.core.result.R;



/**
 * 角色权限表
 *
 * @author hhp
 * @email 2437579794@qq.com
 * @date 2021-11-23 10:25:32
 */
@RestController
@RequestMapping("/api/v1/admin/rolePermission")
public class RolePermissionController {
    @Autowired
    private RolePermissionService rolePermissionService;


    /**
     * 信息
     */
    @ApiOperation(value = "角色权限详情")
    @ApiImplicitParam(name = "id", value = "角色id", required = true, paramType = "path", dataType = "Long")
    @GetMapping("/{roleId}")
    public R info(@PathVariable("roleId") Integer roleId){
        return R.ok().setData(rolePermissionService.getById(roleId));
    }

    /**
     * 保存
     */
    @ApiOperation(value = "新增角色权限")
    @PostMapping
    public R save(@RequestBody RolePermissionEntity rolePermission){
		rolePermissionService.save(rolePermission);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改角色权限")
    @PutMapping
    public R update(@RequestBody RolePermissionEntity rolePermission){
		rolePermissionService.updateById(rolePermission);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除角色权限")
    @DeleteMapping
    public R delete(@RequestBody Integer[] roleIds){
		rolePermissionService.removeByIds(Arrays.asList(roleIds));

        return R.ok();
    }

}
